#include "gl_parser.h"

#include "bd_gps.h"
#include "stdio.h"
#include "ble.h"
#include "sbus.h"

#include "FreeRTOS.h"
#include "task.h"
#include "cmsis_os.h"

struct RC_VALUE_STRUCT rc_value_s;
struct BD_GPS_STRUCT bd_gps_rc_s;
extern uint16_t rc_data[16];
void parse_status_frame(PARSE_STRUCT *parser_s)
{
    uint8_t error_code;
    FRAME_STRUCT frame_s;
    frame_s.Version = PROTOCOL_VERSION;
    frame_s.FrameDataLen = 0;
    frame_s.frame_data = NULL;
    frame_s.send_frame_fun = parser_s->frame_s.send_frame_fun;
    frame_s.MasterCmd = MASTER_CMD_STATUS;

    if(parser_s->frame_s.MasterCmd != MASTER_CMD_STATUS)
    {
        frame_s.SlaveCmd = SLAVE_CMD_STATUS_ERROR;
    }else{
        switch(parser_s->frame_s.SlaveCmd)
        {
            case SLAVE_CMD_STATUS_GPS:
            
            memcpy(&bd_gps_rc_s,parser_s->frame_s.frame_data,sizeof(struct BD_GPS_STRUCT));
            
            frame_s.SlaveCmd = SLAVE_CMD_STATUS_GPS_SUCCESS;
            frame_s.FrameDataLen = 0;
            frame_s.frame_data = NULL;
            break;  
            
            case SLAVE_CMD_RC_VALUE:
            
            memcpy(&rc_value_s,parser_s->frame_s.frame_data,sizeof(struct RC_VALUE_STRUCT));
            rc_data[0] = rc_value_s.rc_data[0];
            rc_data[1] = rc_value_s.rc_data[1];
            break; 
            
            default:
            frame_s.SlaveCmd = SLAVE_CMD_STATUS_ERROR;
            break;
        }
    }

    //creat_send_cmd(&frame_s);
}

